package com.xiaonei.DAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.util.DBConnection;
import com.xiaonei.model.*;


public class User1DAO implements IUser1DAO{

	@Override
	public int getSchoolNumByAccount(String account) {
		 int schoolNum = 100;
		   Connection conn=DBConnection.getConnection();//寰楀埌鏁版嵁搴撶殑杩炴帴锟�		
		   ResultSet rs=null;//缁撴灉锟�		
		   PreparedStatement pstmt=null;
			
			String sql="select school_num from user1 where account='"+account+"'";
			try{
				pstmt=conn.prepareStatement(sql);
				rs=pstmt.executeQuery();
				while(rs.next()){
				schoolNum=rs.getInt(1);
				}	
			}catch(Exception e){
				e.printStackTrace();
			}finally{
				DBConnection.free(rs, conn, pstmt);
			}
			return schoolNum;
	}

	@Override
	public String getNickName(String account) {
		String nickName="ANTUHOR浣犲弬鑰";
		   Connection conn=DBConnection.getConnection();//寰楀埌鏁版嵁搴撶殑杩炴帴锟�		
		   ResultSet rs=null;//缁撴灉锟�		
		   PreparedStatement pstmt=null;
			
			String sql="select nickName from user1 where account='"+account+"'";
			try{
				pstmt=conn.prepareStatement(sql);
				rs=pstmt.executeQuery();
				while(rs.next()){
				nickName=rs.getString(1);
				}	
			}catch(Exception e){
				e.printStackTrace();
			}finally{
				DBConnection.free(rs, conn, pstmt);
			}
			return nickName;
	}

	
	
}
